public class CopyPerson {

    public static void main(String[] args) {

        Person p = new Person();
        p.name = "milan";
        p.age = 20;

        MyTools tools = new MyTools();
        Person p2 = tools.copyPerson(p);

        System.out.println(p2.name);
        System.out.println(p2.age);
//      查看是否为同一个对象
        System.out.print(p == p2);
    }


}

class Person{

    String name;
    int age;

}

class MyTools{

    public Person copyPerson(Person p) {

        Person p2 = new Person();
        p2.name = p.name;
        p2.age = p.age;

        return p2;
    }

}



